home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Mar 14, 1997
- //
- // Description:
- // This script is defines the option box for the loft menu item.
- //
-
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- if ($forceFactorySettings || !`optionVar -exists loftUniform`) {
- optionVar -intValue loftUniform 1;
- }
- if ($forceFactorySettings || !`optionVar -exists loftClose`) {
- optionVar -intValue loftClose 0;
- }
- if ($forceFactorySettings || !`optionVar -exists loftAutoReverse`) {
- optionVar -intValue loftAutoReverse 1;
- }
- if ($forceFactorySettings || !`optionVar -exists loftDegree`) {
- optionVar -intValue loftDegree 3;
- }
- if( $forceFactorySettings || !`optionVar -exists loftRange`) {
- optionVar -intValue loftRange 0;
- }
- if( $forceFactorySettings || !`optionVar -exists loftPolys`) {
- optionVar -intValue loftPolys 0;
- }
- if( $forceFactorySettings || !`optionVar -exists loftSectionSpans`) {
- optionVar -intValue loftSectionSpans 1;
- }
- }
-
- //
- // Procedure Name:
- // loftSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
-
- global proc loftSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars( $forceFactorySettings );
- loftToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Query the optionVar's and set the values into the controls
- //
- int $uniform = `optionVar -query loftUniform`;
- int $autoReverse = `optionVar -query loftAutoReverse`;
- int $close = `optionVar -query loftClose`;
- int $degree = `optionVar -query loftDegree`;
- int $range = `optionVar -query loftRange`;
- int $polys = `optionVar -q loftPolys`;
- int $spans = `optionVar -query loftSectionSpans`;
- if( ! `isTrue "SurfaceUIExists"` ) $polys = 1;
-
- // Set the controls
- //
- radioButtonGrp -edit -select (2 - $uniform) uniformRadio;
- checkBoxGrp -edit -value1 $autoReverse autoReverseCloseCheck;
- checkBoxGrp -edit -value2 $close autoReverseCloseCheck;
- if( 3 == $degree ) radioButtonGrp -edit -select 2 degreeRadio;
- else radioButtonGrp -edit -select 1 degreeRadio;
- radioButtonGrp -edit -select ($range + 1) rangeRadio;
- if( `isTrue "SurfaceUIExists"` ) {
- if( (3 == $polys) && ! `isTrue "SubdivUIExists"` ) {
- $polys = 2;
- }
- radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp;
- }
- intSliderGrp -e -v $spans sectionSpansInt;
-
- switch( $polys ) {
- case 0:
- default:
- tabLayout -e -st polyOptionsNo polyOptions;
- break;
- case 1:
- tabLayout -e -st polyOptionsOK polyOptions;
- break;
- case 2:
- tabLayout -e -st polyOptionsSubdiv polyOptions;
- break;
- case 3:
- tabLayout -e -st polyOptionsBezier polyOptions;
- break;
- }
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
-
- nurbsToPolySetup( $parent, $forceFactorySettings );
- nurbsToSubdivSetup( $parent, $forceFactorySettings );
- }
-
- //
- // Procedure Name:
- // loftCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
-
- global proc loftCallback(string $parent, int $doIt, string $goToTool)
- {
- if( "" != $goToTool ) {
- optionVar -iv loftEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv loftLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Set the optionVar's from the current control values, and then perform
- // the command
- //
- int $uniform = 2 - `radioButtonGrp -q -select uniformRadio`;
- int $autoReverse = `checkBoxGrp -query -v1 autoReverseCloseCheck`;
- int $close = `checkBoxGrp -query -v2 autoReverseCloseCheck`;
- int $degree = `radioButtonGrp -q -select degreeRadio`;
- int $spans = `intSliderGrp -q -v sectionSpansInt`;
- if( 1 != $degree ) $degree = 3;
- int $range = `radioButtonGrp -q -select rangeRadio` - 1;
- if( `isTrue "SurfaceUIExists"` ) {
- int $polygons = `radioButtonGrp -q -select outputPolyRadioButtonGrp`;
- if( (3 == $polygons) && ! `isTrue "SubdivUIExists"` ) {
- $polygons = 4;
- }
- optionVar -intValue loftPolys ($polygons-1);
- }
-
- optionVar -intValue loftUniform $uniform;
- optionVar -intValue loftClose $close;
- optionVar -intValue loftAutoReverse $autoReverse;
- optionVar -intValue loftDegree $degree;
- optionVar -intValue loftRange $range;
- optionVar -intValue loftSectionSpans $spans;
-
- nurbsToPolyCallback( $parent, 0 );
- nurbsToSubdivCallback( $parent, 0 );
-
- if( 1 == $doIt ) {
- performLoft( 0, $goToTool );
- string $tmpCmd = "performLoft(0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Loft";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // loftOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- proc loftOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "loft";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Step 1: Get the option box.
- // ============================
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolLoft";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "loftToolScript 3";
-
- string $layout = getOptionBox();
- setParent $layout;
-
- // Step 2: Pass the command name to the option box.
- // =================================================
- setOptionBoxCommandName($commandName);
-
- // Step 3: Activate the default UI template.
- // ==========================================
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Step 4: Create option box contents.
- // ===================================
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -label "Parameterization"
- -label1 "Uniform"
- -label2 "Chord Length"
- uniformRadio;
-
- checkBoxGrp -ncb 2
- -l1 "Auto Reverse"
- -l2 "Close"
- autoReverseCloseCheck;
-
- radioButtonGrp -nrb 2
- -l "Surface Degree"
- -l1 "Linear"
- -l2 "Cubic"
- degreeRadio;
-
- intSliderGrp
- -l "Section Spans"
- -min 1
- -max 10
- -fmn 1
- -fmx 500
- sectionSpansInt;
-
- separator;
-
- radioButtonGrp -numberOfRadioButtons 2
- -label "Curve Range"
- -label1 "Complete"
- -label2 "Partial"
- rangeRadio;
-
- if( `isTrue "SubdivUIExists"` ) {
- radioButtonGrp -nrb 4
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Subdiv"
- -label4 "Bezier"
- -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
- -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
- -cc3 "tabLayout -e -st polyOptionsSubdiv polyOptions"
- -cc4 "tabLayout -e -st polyOptionsBezier polyOptions"
- outputPolyRadioButtonGrp;
- }
- else if( `isTrue "SurfaceUIExists"` ) {
- radioButtonGrp -nrb 3
- -label "Output Geometry"
- -label1 "Nurbs"
- -label2 "Polygons"
- -label3 "Bezier"
- -cc1 "tabLayout -e -st polyOptionsNo polyOptions"
- -cc2 "tabLayout -e -st polyOptionsOK polyOptions"
- -cc3 "tabLayout -e -st polyOptionsBezier polyOptions"
- outputPolyRadioButtonGrp;
- }
-
- separator;
-
- tabLayout -tabsVisible false polyOptions;
- string $par = `columnLayout polyOptionsOK`;
- nurbsToPolyAddOptions $par;
- setParent ..;
- columnLayout polyOptionsNo;
- setParent ..;
- columnLayout polyOptionsSubdiv;
- nurbsToSubdivAddOptions $par;
- setParent ..;
- columnLayout polyOptionsBezier;
- setParent ..;
- setParent ..;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Loft Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Loft"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Loft Tool Options");
- } else {
- setOptionBoxTitle("Loft Options");
- }
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "Loft" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // loftHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
-
- proc string loftHelp()
- {
- return
- " Command: Loft - loft a number of curves (or add to lofted surface)\n" +
- "Selection: curve, curve on surface, surface isoparm";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "doPerformLoft";
-
- setOptionVars(false);
-
- int $history = `constructionHistory -q -tgl`;
- int $uniform = `optionVar -q loftUniform`;
- int $autoReverse = `optionVar -q loftAutoReverse`;
- int $close = `optionVar -q loftClose`;
- int $degree = `optionVar -q loftDegree`;
- int $spans = `optionVar -q loftSectionSpans`;
- int $range = `optionVar -q loftRange`;
- int $polys = `optionVar -q loftPolys`;
- if( ! `isTrue "SurfaceUIExists"` ) $polys = 1;
-
- $cmd = $cmd + "(";
- $cmd = $cmd + "\"1\"" + ", {";
- $cmd = $cmd + "\"" + $history + "\",";
- $cmd = $cmd + "\"" + $uniform + "\",";
- $cmd = $cmd + "\"" + $autoReverse + "\",";
- $cmd = $cmd + "\"" + $close + "\",";
- $cmd = $cmd + "\"" + $degree + "\",";
- $cmd = $cmd + "\"" + $spans + "\",";
- $cmd = $cmd + "\"" + $range + "\",";
- $cmd = $cmd + "\"" + $polys + "\"";
- $cmd = $cmd + "} )";
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performLoft
- //
- // Description:
- // Perform the loft command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the loft command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- // 3 - Show the tool option box dialog.
- //
- // Return Value:
- // None.
- //
-
- global proc string performLoft(int $action, string $goToTool)
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
- case 1:
- loftOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-